home *** CD-ROM | disk | FTP | other *** search
- /*
- File: ModemStub.c
-
- Contains: Shell for the USB Modem driver
-
- Version: xxx put version here xxx
-
- Copyright: © 1998 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #include <Errors.h>
-
- #include "Modem.h"
- #include "ModemStub.h"
- #include "ModemDriver.h"
- #include "ShimSerialStub.h"
- #include "ShimSerialHAL.h"
-
- //------------------------------------------------------
- //
- // Globals
- //
- //------------------------------------------------------
-
- ShimSerialGlobals* gGlobals;
-
- //------------------------------------------------------
- //
- // This is the driver description structure that the expert looks for first.
- // If it's here, the information within is used to match the driver
- // to the device whose descriptor was passed to the expert.
- // Information in this block is also used by the expert when an
- // entry is created in the Name Registry.
- //
- //------------------------------------------------------
-
- USBDriverDescription TheUSBDriverDescription =
- {
- // Signature info
- kTheUSBDriverDescriptionSignature,
- kInitialUSBDriverDescriptor,
-
- // Device Info
- kUSBVendor, // vendor ID
- kUSBProduct, // product ID
- 0, // version of product = not device specific
- 0, // protocol = not device specific
-
- // Interface Info
- 0, // Configuration Value
- 0, // Interface Number
- 255, // Interface Class
- 255, // Interface SubClass
- 255, // Interface Protocol
-
- // Driver Info
- kModemName, // Driver name for Name Registry
- 0, // Device Class
- 0, // Device Subclass
- 0x1, 0x0, alphaStage, 0x1, // version of driver = 1.0a1
-
- // Driver Loading Info
- kUSBDoNotMatchGenericDevice // Flags
- };
-
- USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
- {
- kClassDriverPluginVersion, // Version of this structure
- modemDriverValidateHW, // Hardware Validation Procedure
- modemDriverInitialize, // Initialization Procedure
- modemDriverInitInterface, // Interface Initialization Procedure
- modemDriverFinalize, // Finalization Procedure
- modemDriverNotifyProc,
- };
-
- CFragConnectionID ConnID; // Need to remember this
-
- /***********************************************************************************/
- // Function: modemDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc)
- // Description: Called upon load by Expert
- //
- // Input: Device reference, Device descriptor
- // Output: noErr
- /***********************************************************************************/
-
- static OSStatus modemDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc)
- {
-
- TraceMessage(0,"\pmodemDriverValidateHW");
- device = 0;
- desc = 0;
- return noErr;
- }
-
- /***********************************************************************************/
- // Function: OSStatus modemDriverInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc,
- // UInt32 busPowerAvailable)
- // Description: Called upon load by Expert
- //
- // Input: Device reference, Device descriptor, bus power available
- // Output: result
- /***********************************************************************************/
-
- static OSStatus modemDriverInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable)
- {
- #pragma unused (busPowerAvailable)
-
- TraceMessage(0,"\pmodemDriverInitialize");
-
- gGlobals = (ShimSerialGlobals*)PoolAllocateResident(sizeof(ShimSerialGlobals),true);
- if (gGlobals == NULL)
- goto bail;
-
- if (pDesc->vendor != USBToHostWord(kUSBVendor))
- {
- StatusMessage(0, "\pClass - Not my device!", 0);
- goto bail;
- }
-
- USBExpertStatus(0, "\pModem driver loading as Class", 0);
-
- modemDriverEntry(device, pDesc);
-
- // Install Device Control Entry for both the ".In" and ".Out functions that are
- // requied for a serial driver which is what we are.
- if (noErr != InstallShimDrvr(ConnID))
- {
- StatusMessage(0, "\pCan't install DCEs!", 0);
- goto bail;
- }
-
- return noErr;
-
- bail:
- if (gGlobals)
- PoolDeallocate(gGlobals);
- gGlobals = NULL;
-
- return openErr;
- }
-
- /***********************************************************************************/
- // Function: modemDriverInitInterface(UInt32 interfaceNum, USBInterfaceDescriptor *interfaceDesc,
- // USBDeviceDescriptor *deviceDesc, USBDeviceRef device)
- // Description: Called to initialize driver for an individual interface -
- // either by expert or internally by driver
- //
- // Input: Interface number, Interface descriptor, Device Descriptor, Device Reference
- // Output: result
- /***********************************************************************************/
-
- static OSStatus modemDriverInitInterface(UInt32 interfaceNum, USBInterfaceDescriptor *interfaceDesc, USBDeviceDescriptor *deviceDesc, USBDeviceRef device)
- {
- #pragma unused (interfaceNum)
- #pragma unused (interfaceDesc)
-
- TraceMessage(0,"\pmodemDriverInitInterface");
-
- if (gGlobals == NULL)
- gGlobals = (ShimSerialGlobals*)PoolAllocateResident(sizeof(ShimSerialGlobals),true);
-
- if (gGlobals == NULL)
- goto bail;
-
- if (deviceDesc->vendor != USBToHostWord(kUSBVendor))
- {
- StatusMessage(0, "\pInterface - Not my device!", 0);
- goto bail;
- }
-
- USBExpertStatus(0, "\pModem driver loading as Interface", 0);
-
- modemDriverEntry(device, deviceDesc);
-
- // Install Device Control Entry for both the ".In" and ".Out functions that are
- // requied for a serial driver which is what we are.
- if (noErr != InstallShimDrvr(ConnID))
- {
- StatusMessage(0, "\pCan't install DCEs!", 0);
- goto bail;
- }
-
- return noErr;
-
- bail:
- if (gGlobals)
- PoolDeallocate(gGlobals);
- gGlobals = NULL;
-
- return openErr;
- }
-
- /***********************************************************************************/
- // Function: modemDriverFinalize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc)
- // Description: Called by Expert when driver is being shut down
- //
- // Input: Device reference, Device descriptor
- // Output: noErr
- /***********************************************************************************/
-
- static OSStatus modemDriverFinalize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc)
- {
-
- TraceMessage(0,"\pmodemDriverFinalize");
-
- device = 0;
- pDesc = 0;
-
- KillUSBIO();
- RemoveShimDrvr(true); // force close - let the shim handle it
-
- if (gGlobals)
- PoolDeallocate(gGlobals);
-
- gGlobals = NULL;
-
- return noErr;
- }
-
- /***********************************************************************************/
- // Function: ExpertEntryProc(ExpertNotificationProcPtr pExpertNotify)
- // Description:
- //
- // Input: Notification proc pointer
- // Output: noErr
- /***********************************************************************************/
-
- static OSStatus ExpertEntryProc(ExpertNotificationProcPtr pExpertNotify)
- {
- pExpertNotify = 0;
- return noErr;
- }
-
- /***********************************************************************************/
- // Function: modemDriverNotifyProc(UInt32 notification, void *pointer)
- // Description:
- //
- // Input: Notification and pointer
- // Output: result
- /***********************************************************************************/
-
- static OSStatus modemDriverNotifyProc(UInt32 notification, void *pointer, UInt32 refCon)
- {
- #pragma unused (notification, pointer)
- OSStatus err = noErr;
-
- TraceMessage(0,"\pmodemDriverNotifyProc");
-
- return err;
- }
-
- /***********************************************************************************/
- // Function: InitDriver(CFragInitBlock *init)
- // Description: This routine saves our connection id
- //
- // Input: init (unused)
- // Output: noErr
- /***********************************************************************************/
-
- OSErr InitDriver(CFragInitBlock *init)
- {
- OSErr err = noErr;
-
- TraceMessage(0, "\pEntering initDriver");
-
- ConnID = init->connectionID;
-
- return err;
- }